<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/jquery.confirm.css"/>
		<style>
		.nPass{
		background-color:rgb(236, 188, 149);
		}
		.pass {
			background-color: #95CFEC;
		}
		
		</style>
	</head>
	<body>
		<div class="am-g">
			<br>
			<div class="am-u-md-9 am-cf" style="position: fixed;top:0;background-color:#fff; z-index:100;width:100%">
       		<p></p><span id="timeout" style="color:red;font-size:30px;">{$timeout}</span>秒后刷新
 	<br>
      <div class="am-g" >
      <div class="am-u-sm-12" style="margin-top:41px;">
        <form class="am-form" >
          <table class="am-table table-main">
            <thead>
              <tr style="position: fixed;top:70px;background-color:#fff;width:100%;">
                <th width="1%" class="table-check"><input id="qx" onclick="ckAll()" type="checkbox" ></th>
				<th width="10%" class="table-type">昵称</th>
				<th width="35%" class="table-type">评论</th>
				<th width="10%" class="table-type">状态</th>
				<th width="15%" class="table-author">评论时间</th>
				<th width="20%" class="table-author">操作</th>
				
              </tr>
          </thead>
          <tbody style="margin-top:140px;">
          	   <!--{foreach key=key from=$sql_list item=sql}-->
            <tr {if $sql.status eq 2}class="nPass"{/if} >
              <td width="1%"><input onchange="changeColor(this)" type="checkbox" name="commentsIds" id="commentsId_{$sql.id}" value="{$sql.id}"></td>
              <td width="10%" onClick="checkedthis(this)">{$sql.nickname}</td>
              <td width="35%" onClick="checkedthis(this)">{$sql.comment|default:" - "}</td>
			  <td width="10%" onClick="checkedthis(this)"> {$sql.statusShow|default:" - "}</td>
			  <td width="15%" onClick="checkedthis(this)">{$sql.create_time|date_format:"Y-m-d H:i:s"}</td>
     		  <td width="20%">
     		  	{if $sql.status eq 0}
					<button  class="am-btn am-btn-default am-btn-xs am-text-secondary " onClick="updateCommentStatus('{$sql.id}',1)"><span class="am-icon-pencil-square-o"></span> 审核通过</button>
					<button class="am-btn am-btn-default am-btn-xs am-text-secondary " onClick="updateCommentStatus('{$sql.id}',2)" ><span class="am-icon-pencil-square-o"></span> 审核不通过</button>
				{else if $sql.status eq 1}
					<button class="am-btn am-btn-default am-btn-xs am-text-secondary " onClick="updateCommentStatus('{$sql.id}',2)" ><span class="am-icon-pencil-square-o"></span> 审核不通过</button>
				{else if $sql.status eq 2}
					<button  class="am-btn am-btn-default am-btn-xs am-text-secondary " onClick="updateCommentStatus('{$sql.id}',1)"><span class="am-icon-pencil-square-o"></span> 审核通过</button>
				{/if}
				
     		  </td>
            </tr>
              <!--{/foreach}-->  
          </tbody>
        </table>
          <div class="am-cf">

  <div class="am-fr" style="margin-right:300px">
  		<div class="hy_page">
			{$list_page}
		</div>
  </div>
</div>
          <hr />
      
        </form>
      </div>

    </div>
	
			<div class="am-fl am-cf" style="position: fixed;left:0%;padding-left:20%;top:87%;background-color:#fff; z-index:100;width:100%;bottom:1%;">
	          <div class="am-btn-toolbar am-fl">
	            <div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="updateAllCommentStatus(1)" id="pass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 批量通过</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="updateAllCommentStatus(2)" id="Nopass_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 批量不通过</a>
	            </div>
				<div class="am-btn-group am-btn-group-xs">
	              <a  href="javascript:void(0);" onclick="refreshNow()" id="refresh_html"  class="am-btn am-btn-default hy-js-href"><span class="am-icon-plus"></span> 刷新</a>
	            </div>
	          </div>
	        </div>
	
	
	
    </div>
{include file='../Common/hy_footer.html'}
<script src="{$_C.hy_path}js/jquery.confirm.js"></script>
	<script type="text/javascript">
		var page='{$page}';
		var  inter;
		var isBusy = false;
		function checkedthis(params){
			if($(params).parent().find("input[name=commentsIds]").attr("checked")!="checked"){
				$(params).parent().find("input[name=commentsIds]").prop("checked","checked");
				$(params).parent().addClass('pass');
			}else{
				$(params).parent().find("input[name=commentsIds]").prop('checked',"");
				$(params).parent().removeClass('pass');
			}
		}
		function changeColor(params){
			if($(params).parent().parent().hasClass('pass')){
				$(params).parent().parent().removeClass('pass');
			}else{
				$(params).parent().parent().addClass('pass');
			}
			
		}
		function updateCommentStatus(id,status){
			if (window.confirm('确定要修改该状态位吗？')) {
				var data = {
					id:id,
					status:status
				}
				var url = "index.php?g=admin&m=npc&a=updateCommentStatus";
				$.post(url,data,function(res){
					showMsg(res.content,res.error);
					if(res.error==0){
						refreshNow();
					}
				},"json")
			}
		}
		function ckAll(){
			var qx = $("#qx");
			$("input[name='commentsIds']").each(function() {
					$(this).prop('checked', qx.prop('checked'));
					if(qx.prop('checked')){
						$(this).parent().parent().addClass('pass');
					}else{
						$(this).parent().parent().removeClass('pass');
					}
				})
		}
		$(function(){
				inter = setInterval('countDown()',1000);
		})
		function countDown(){
			var timeout = parseInt($("#timeout").html());
			timeout--;
			$("#timeout").html(timeout);
			if (timeout<=0) {
				clearInterval(inter);
				refreshNow();
			}else{
				
			}
		}
		
		function updateAllCommentStatus(status){
			if (window.confirm('确定要批量修改状态位吗？')) {
				var check_arr = new Array;
				$("input[name='commentsIds']:checked").each(function() {
					check_arr.push($(this).val())
				})
				var data = {
					id:check_arr,
					status:status
				}
				var url = "index.php?g=admin&m=npc&a=updateCommentStatus";
				$.post(url,data,function(res){
					showMsg(res.content,res.error);
					if(res.error==0){
						refreshNow();
					}
				},"json")
			}
		}
		
		function refreshNow(){
			$("#refresh_html").html("<span class='am-icon-plus'></span> 刷新中...");
			parent.$('#review-side').attr('src', parent.$('#review-side').attr('src'));
		}
	</script>
	
	</body>
</html>
